package com.wyfan.scaffold.common.nacos;

import com.alibaba.nacos.spring.context.annotation.config.NacosPropertySource;
import com.wyfan.scaffold.common.util.SpringContextUtils;
import lombok.Data;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

/**
 * nacos 配置文件
 * tips：本地配置文件有定义的参数不会从nacos拉取
 */
@Data
//@Component
@NacosPropertySource(dataId = "${nacos.config.data-id}", autoRefreshed = true, groupId = "${nacos.config.group}")
public class NacosConfig {

    static NacosConfig config;

    public static NacosConfig getInstance() {
        if (config == null) config = SpringContextUtils.getBean(NacosConfig.class);
        return config;
    }

    @Value("${test:1}")
    private String test;

}
